using System;
using Serpis;

namespace PArticulo
{
	public partial class ArticuloNew : Gtk.Window
	{
		public event EventHandler Save;
		
		public ArticuloNew () : base(Gtk.WindowType.Toplevel)
		{
			this.Build ();
			spinbuttonPrecio.Adjustment.StepIncrement=0.5;
			micombobox.Init(AppDbConnection.Instance.DbConnection, "SELECT * FROM categoria;");
			micombobox.Id="";
			
			buttonSave.Clicked+=delegate
			{
				raiseSave();
			};

		}
			public string Nombre 
			{
				get {return entryNombre.Text;}
			}
			
			public decimal Precio 
			{
				get {return Convert.ToDecimal(spinbuttonPrecio.Value);}
			}
			
			public long? Categoria 
			{
				get {return micombobox.Id == "" ? (long?)null : Convert.ToInt64(micombobox.Id);}
				set {micombobox.Id= value.ToString();}
			}
			
			private void raiseSave() 
			{
				if(Save != null)
				{
					Save(this, EventArgs.Empty);
				}
			}
	}
}

